import shutil

import openpyxl
import datetime

import os
from openpyxl.utils import get_column_letter
from openpyxl.styles import Alignment, Side, PatternFill, Border, Font
from tools_pmc import (fill_blue, fill_yellow,
                       table_array_wlxxb,
                       today_str1, yesterday_str2, yesterday_str1,
                       alignment_center, alignment_left, alignment_right,
                       vlookup, vlookup_two, detect_date_str,
                       lj_wlxxb, lj_mccr, lj_test1, font_ERP, alignment_erp_r, border_gray, fill_erp, alignment_erp_l,
                       alignment_wrap_text_F, detect_date, lj_JH0020, lj_msd, lj_change_ms, lj_msd_md,
                       lj_mccr_yesterday, lj_JH0020_1, erp_fc_2, erp_fc_1, lj_bom, bom_1, bom_start_1
                       )

lj_tdl_ztbg = r"\\192.168.70.101\19计划管理部\01.计划\5，物控管理\1，替代料管理\替代料管理看板.xlsx"
wb = openpyxl.load_workbook(lj_tdl_ztbg)
ws = wb.worksheets[0]

wb_bom = openpyxl.load_workbook(lj_bom)
ws_bom = wb_bom.worksheets[0]
while True:
    sn = str(input("请输入成品品号:"))
    list_bom_1 = bom_1(sn, ws_bom)
    str1 = vlookup(sn, table_array_wlxxb, 3) + "(" + sn + ")\n以下优先使用替代料:\n"
    for i in range(3, ws.max_row + 1):
        if ws.cell(i, 4).value is not None:
            if sn in ws.cell(i, 4).value or ws.cell(i, 4).value == "通用替代" and ws.cell(i,1).value in list_bom_1[0]:
                if ws.cell(i, 6).value == "优先消耗":
                    str1 += (str(ws.cell(i, 1).value) + "->" + str(ws.cell(i, 5).value) + "(" + str(
                        ws.cell(i, 7).value) + ")\n")
    print(str1)
